import Vue from 'vue'
import Vuex from 'vuex'
import dialog from './dialog.js'
import login from './login.js'
import chat from './chat.js'
import g from './group.js'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    nick: '',
    groups: [],
    tempGroups: [],
    rightMenuIndex: -1,
    isShowRightMenu: false,
    rightMenuX: 0,
    rightMenuY: 0,
    rightMenuActiveGroupNum: -1,
    routerIndex: '/index/chat',
    isConnect: false,
    isLoadOk: false
  },
  mutations: {
    // 数据加载完成
    setIsLoadOk_fn(state) {
      state.isLoadOk = true
    },
    // 设置已连接到服务器
    setConnectSuccess_fn(state) {
      state.isConnect = true
    },
    // 更新昵称
    updateNick_fn(state, nick) {
      state.nick = nick
    },
    // 更改群数组列表
    updateGroups_fn(state, list) {
      state.groups = list
    },
    // 更改临时群数组列表
    updateTempGroups_fn(state, list) {
      state.tempGroups = list
    },
    // 更改右键菜单是否显示
    updateRightMenuShow_fn(state, boo) {
      state.isShowRightMenu = boo
    },
    // 更改右键菜单选中的菜单索引
    updateRightMenuIndex_fn(state, index) {
      state.rightMenuIndex = index
    },
    // 更改右键菜单选中的群号
    updateRightMenuActiveGroupNum_fn(state, num) {
      state.rightMenuActiveGroupNum = num
    },
    // 更改app路由index
    updateRouterIndex_fn(state, path) {
      state.routerIndex = path
    }
  },
  actions: {
  },
  modules: {
    dialog,
    login,
    chat,
    g
  }
})
